<html>
<head>

<script type="text/javascript">
function getJSONP(url) {

	var script = document.createElement('script');
	var head = document.getElementsByTagName('head')[0] || document.documentElement;

    script.src = url;
    head.appendChild(script);

}

function getJSONP2(url, success) {

    var ud = '_' + +new Date,
        script = document.createElement('script'),
        head = document.getElementsByTagName('head')[0] 
               || document.documentElement;

    window[ud] = function(data) {
        head.removeChild(script);
        success && success(data);
    };

    script.src = url.replace('callback=?', 'callback=' + ud);
    head.appendChild(script);

}

function onPing() {
	alert('onPing callback is called');
}

function onHeartbeat() {
	alert('onHeartbeat callback is called');
}

function onHeartbeat() {
	alert('onHeartbeat callback is called');
}

function onGetSystemInfo(data) {
	var output = JSON.stringify(data);
	alert('onHeartbeat callback is called. Data received: ' + output);
}


</script>

</head>
<body>
<h1>Rise Player 2.0 API Test</h1>

<hr>
<h2>Ping</h2>
<button type="button" onclick="getJSONP('http://localhost:9449/ping?callback=onPing')">Click Me!</button>

<hr>
<h2>Heartbeat</h2>
<button type="button" onclick="getJSONP('http://localhost:9449/heartbeat?callback=onHeartbeat')">Click Me!</button>

<hr>
<h2>Get System Info</h2>
<button type="button" onclick="getJSONP('http://localhost:9449/get_system_info?callback=onGetSystemInfo')">Click Me!</button>

<hr>
<h2>Save Property (save Display ID and Claim ID into display.properties file)</h2>
<span>URL:</span>
<input type="text" value="http://localhost:9449/save_property?display_id=123456&claim_id=654321" style="width: 500px;"> <br>
<button type="button" onclick="getJSONP('http://localhost:9449/save_property?display_id=123456&claim_id=654321'); alert('Done');">Click Me!</button>

<hr>
<h2>Restart (restart PC)</h2>
<button type="button" onclick="getJSONP('http://localhost:9449/restart')">Click Me!</button>

<hr>
<h2>Shutdown (close  Rise Player)</h2>
<button type="button" onclick="getJSONP('http://localhost:9449/shutdown')">Click Me!</button>

<hr>
<h2>Set Upgrade Info</h2>
<button type="button" onclick="getJSONP('http://localhost:9449/set_upgrade_info?info=aa%3Dbb%0Acc%3Dvv'); alert('Done');">Click Me!</button>

<hr>
<h2>Get Upgrade Info</h2>
<button type="button" onclick="window.open('http://localhost:9449/get_upgrade_info')">Click Me!</button>

<hr>
<h2>Version</h2>
<button type="button" onclick="window.open('http://localhost:9449/version')">Click Me!</button>
</body>
</html>